/**
* @author maze | guavestudios.com
* @license MIT License see LICENSE.TXT
* @version 0.1
*/
package com.guavestudios.fcon.plugins {
	import flash.events.EventDispatcher;
	import flash.net.URLRequest;
	import flash.utils.Dictionary;
	import com.guavestudios.fcon.api.INamedCommand;
	
	/**
	* Commandmanager is for storing and manage commands
	*/
	public class CommandManager extends EventDispatcher {
		
		//{ STATIC
	
		//}
		
		//{ MEMBERS
		private var commands:Dictionary;
		//}
		
		//{ GETTER-SETTER
		
		//}
		public function CommandManager():void {
			
			commands=new Dictionary();
			init();
		}
		private function init():void {
			
		}
		//{ PUBLIC FUNCTIONS
		/**
		* Register a command
		* @param	c	command with unique name
		*/
		public function addCommand(c:INamedCommand):void
		{
			Console.trace("(CommandManager.addCommand) "+c.getCommandName());
			commands[c.getCommandName()]=c;
		}
		/**
		* remove a command
		* @param	c	command itself
		*/
		public function removeCommand(c:INamedCommand):void
		{
			commands[c.getCommandName()]=undefined;
		}
		/**
		* adds an alias for a command
		* @param	al	alias forcommand
		* @param	cmd	command referenced
		*/
		public function addAlias(al:String,cmd:INamedCommand):void
		{
			commands[al]=cmd;
		}
		/**
		* remove an alias
		* @param	al	alias id
		*/
		public function removeAlias(al:String):void
		{
			commands[al]=undefined;
		}
		/**
		* returns a registered command by name
		* @param	scmd	unique command name
		* @return	searched command
		*/
		public function getCommand(scmd:String):INamedCommand
		{
			return commands[scmd];
		}
		/**
		* return all commands in a list
		* @return	all commands
		*/
		public function getCommands():Dictionary
		{
			return commands;
		}
		//}
		
		//{ OVERRIDEN METHODS
		
		//}
		
		//{ PRIVATE FUNCTIONS
		
		//}

	}
	
}
